# 地址：http://121.40.86.4:8899/admin/login
# 账号：admin
# 密码：Aa010903!
# 用例一：
# 1、用户登录
# 2、点击用户
# 3、点击用户分组
# 4、添加用户分组
# 5、判断添加是否成功
# 6、删除用户分组
# 7、判断删除是否是成功的
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait  # 强制等待的方法
from selenium.webdriver.support import expected_conditions as EC   # 如果找不到则抛出异常
# 实例化驱动
driver = webdriver.Chrome()
# 打开网页
driver.get("http://121.40.86.4:8899/admin/login")
# 全屏化
driver.maximize_window()
# 设置隐式等待
driver.implicitly_wait(15)
# 输入账号
driver.find_elements(By.CLASS_NAME,"el-input__inner")[0].send_keys("admin")
# 输入密码
driver.find_elements(By.CLASS_NAME,"el-input__inner")[1].send_keys("Aa010903!")
# 点击登录按钮
driver.find_element(By.XPATH,"//*[text()='登录']").click()
time.sleep(2)
# 点击用户
# driver.find_elements(By.CLASS_NAME,"font12")[1].click()
# time.sleep(2)
# 点击用户分组
# driver.find_element(By.XPATH,"//*[text()='用户分组']").click()
# time.sleep(2)
# 点击添加分组
# driver.find_element(By.XPATH,"//*[text()='添加分组']").click()
# time.sleep(2)
# 输入分组名称 hello
# driver.find_elements(By.CLASS_NAME,"el-input__inner")[0].send_keys("hello")
# time.sleep(2)
# 点击确定
# driver.find_elements(By.CLASS_NAME,"el-button")[2].click()
# time.sleep(2)
# 点击删除
# driver.find_element(By.XPATH,"//*[@id='app']/section/div[2]/section/div/div[1]/div/main/div/div[1]/div/div[1]/div/div/div/div[2]/div[4]/div[2]/table/tbody/tr[3]/td[3]/div/a[2]").click()
# time.sleep(2)
# # 点击确认删除
# driver.find_elements(By.CLASS_NAME,"el-button")[2].click()
# time.sleep(2)

# 判断添加是否成功
# text = driver.find_element(By.XPATH,"//*[@id='app']/section/div[2]/section/div/div[1]/div/main/div/div[1]/div/div[1]/div/div/div/div[2]/div[3]/table/tbody/tr[1]/td[2]/div/span").text
# assert text =="hello"
# time.sleep(2)




# 用例二：
# 1、登录
# 2、点击客服
driver.find_elements(By.CLASS_NAME,"font12")[6].click()
time.sleep(2)
# 3、客服话术
driver.find_element(By.XPATH,"//*[text()='客服话术']").click()
time.sleep(2)
# 4、新增客服话术
# driver.find_element(By.XPATH,"//*[text()='添加话术']").click()
# time.sleep(2)
# driver.find_elements(By.CLASS_NAME,"el-textarea__inner")[1].send_keys("nihao")
# time.sleep(2)
# driver.find_elements(By.CLASS_NAME,"el-textarea__inner")[0].send_keys("nihao1")
# time.sleep(1)
# driver.find_elements(By.CLASS_NAME,"el-button")[2].click()
# time.sleep(2)
# 5、看新增是否是成功的
text = driver.find_element(By.XPATH,"//*[@id='app']/section/div[2]/section/div/div[1]/div/main/div/div[1]/div/div[1]/div/div/div[2]/div/div/div[2]/div[3]/table/tbody/tr[11]/td[3]/div/span").text
assert text == "nihao1"
time.sleep(2)



